package tmt.usercenter.web.domain;

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.voodoodyne.jackson.jsog.JSOGGenerator;
import lombok.Getter;
import lombok.Setter;
import tmt.usercenter.web.domain.enums.UserBindingType;

import javax.persistence.*;
import java.io.Serializable;

/**
 * 用户账号绑定的第三方账号。
 * 作者：ThreeManTeam
 * 创建时间：2019-04-23 17:39
 */
@Getter
@Setter
@Entity
@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
@JsonIdentityInfo(generator = JSOGGenerator.class)
public class UserBinding extends BaseDomain implements Serializable {

    /**
     * 第三方系统内用户的唯一ID
     */
    @Column(nullable = false)
    private String openId;

    /**
     * 绑定类型。
     */
    @Enumerated(EnumType.STRING)
    @Column(nullable = false)
    private UserBindingType bindingType = UserBindingType.WEI_XIN;

    /**
     * 本地用户。
     */
    @ManyToOne(cascade = {CascadeType.REFRESH}, fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "user_id", nullable = false)
    private TmtUser user;


}
